package com.it.bigdata.schedual.impl;

import com.it.bigdata.schedual.Schedual;

import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;

public class BaiDuTieBaSchedualForQueue implements Schedual {
    private long currentPageNum = 0L;

    private BaiDuTieBaSchedualForQueue() {
    }

    public static final BaiDuTieBaSchedualForQueue bdSchedual = new BaiDuTieBaSchedualForQueue();

    public static BaiDuTieBaSchedualForQueue getBdQueue() {
        return bdSchedual;
    }

    //高并发的队列是用来存储文章的url列表,让调度器来进行调度
    Queue<String> queue = new ConcurrentLinkedQueue();

    @Override
    public void push(String str) {
        queue.offer(str);
    }

    @Override
    public String pop() {
        return queue.poll();
    }

    public Long getCurrentPageNum() {
        return currentPageNum;
    }

    public void nextPage() {
        currentPageNum += 50;
    }
}
